﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WPF.DazzleUI.Controls;
using WPF.DazzleUI.Presentation;

namespace Demo
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : DazzleWindow
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            ColorPicker cw = new ColorPicker();
            cw.ColorChangeEvent += new Action<Color>(cw_ColorChangeEvent);
            cw.ShowDialog();
            cw.ColorChangeEvent -= cw_ColorChangeEvent;
            //var dictionaries = Application.Current.Resources.MergedDictionaries;

            //Application.Current.Resources["Color_ImageOrColor"] = Visibility.Visible;
            //Application.Current.Resources["Image_ImageOrColor"] = Visibility.Collapsed;
        }

        void cw_ColorChangeEvent(Color obj)
        {
            AppearanceManager.SetTheme(obj);
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog f = new Microsoft.Win32.OpenFileDialog();
            f.Filter = "图像文件(*.bmp, *.jpg)|*.bmp;*.jpg";
            if (f.ShowDialog() == true)
            {
                // Create source.
                BitmapImage bi = new BitmapImage();
                // BitmapImage.UriSource must be in a BeginInit/EndInit block.
                bi.BeginInit();
                bi.UriSource = new Uri(f.FileName, UriKind.RelativeOrAbsolute);
                bi.EndInit();

                AppearanceManager.SetTheme(bi);
            }
            //Application.Current.Resources["Color_ImageOrColor"] = Visibility.Collapsed;
            //Application.Current.Resources["Image_ImageOrColor"] = Visibility.Visible;
        }
    }
}
